home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 2
/
Amiga Tools 2.iso
/
tex
/
macros
/
source
/
base
/
usrguide.tex
/
node18_mn.html
< prev
next >
Wrap
Text File
|
1995-03-15
|
3KB
|
88 lines
<H2><A ID="SECTION00044000000000000000">
Definitions</A>
</H2>
In L<SUP><SMALL>A</SMALL></SUP>T<SMALL>E</SMALL>X, commands can have both mandatory and optional arguments,
for example in:
<PRE><tex2html_verbatim_mark>verbatim45#</PRE>
the |11pt| argument is optional, whereas the |article| class name is
mandatory.
In L<SUP><SMALL>A</SMALL></SUP>T<SMALL>E</SMALL>X~2.09 users could define commands with arguments, but these
had to be mandatory arguments. With L<SUP><SMALL>A</SMALL></SUP>T<SMALL>E</SMALL>X2<SUB>e</SUB>, users can now define
commands and environments which also have one optional argument.
<BR>
<tex2html_image_mark>#decl247#
<BR>
These commands have a new, second, optional argument; this is used for
defining commands which themselves take one optional argument. This
new argument is best introduced by means of a simple (and hence not
very practical) example:
<PRE><tex2html_verbatim_mark>verbatim46#</PRE>
This defines || to be a command with two arguments, referred
to as |#1| and |#2| in the <#259#>definition<#259#>---nothing new so far. But
by adding a second optional argument to this | | (the
|[YYY]|) the first argument (|#1|) of the newly defined command
|| is made optional with its default value being |YYY|.
Thus the usage of || is either:
<PRE><tex2html_verbatim_mark>verbatim47#</PRE>
which prints:
<BLOCKQUOTE>
Mandatory arg: BBB;
Optional arg: YYY.
</BLOCKQUOTE>
or:
<PRE><tex2html_verbatim_mark>verbatim48#</PRE>
which prints:
<BLOCKQUOTE>
Mandatory arg: AAA;
Optional arg: XXX.
</BLOCKQUOTE>
The default value of the optional argument is <TT>YYY</TT>.
This value is specified as the <#269#>default<#269#> argument of the
| | that created ||.
As another more useful example, the definition:
<PRE><tex2html_verbatim_mark>verbatim49#</PRE>
means that the input |<tex2html_image_mark>#tex2html_wrap_inline1995#<I>a</I>| produces
the formula <tex2html_verbatim_mark>#math68#{<I>a</I><SUB>0</SUB>,…, <I>a</I><SUB>n</SUB>},
whereas the input |<tex2html_verbatim_mark>#math69#<tex2html_image_mark>#tex2html_wrap_inline1998#[<I>k</I>]<I>x</I>| produces the formula
<tex2html_verbatim_mark>#math70#{<I>x</I><SUB>0</SUB>,…, <I>x</I><SUB>k</SUB>}.
In summary, the command:
<BLOCKQUOTE>
| | <#279#>cmd<#279#> <#280#>num<#280#> <#281#>default<#281#> <#282#>definition<#282#>
</BLOCKQUOTE>
defines <#284#>cmd<#284#> to be a command with <#285#>num<#285#> arguments, the first of
which is optional and has default value <#286#>default<#286#>.
Note that there can only be one optional argument but, as before,
there can be up to nine arguments in total.
<BR>
<tex2html_image_mark>#decl287#
<BR>
L<SUP><SMALL>A</SMALL></SUP>T<SMALL>E</SMALL>X2<SUB>e</SUB> also supports the creation of environments that have one
optional argument. Thus the syntax of these two commands has
been extended in the same way as that of | |.
<BR>
<tex2html_image_mark>#decl299#
<BR>
This takes the same arguments as | |. If <#305#>cmd<#305#> is already
defined then the existing definition is kept; but if it is currently
undefined then the effect of |is to define <#306#>cmd<#306#>
just as if | | had been used.
<BR>
<tex2html_image_mark>#NEWfeature307#
<BR>